001 /* 002 * Copyright 2005 Stephen J. McConnell 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 013 * implied. 014 * 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019 package net.dpml.library.info; 020 021 import net.dpml.lang.AbstractDirective; 022 023 import net.dpml.library.Info; 024 025 /** 026 * Info block descriptor. 027 * 028 * @author <a href="http://www.dpml.net">Digital Product Meta Library</a> 029 * @version 1.1.0 030 */ 031 public final class InfoDirective extends AbstractDirective implements Info 032 { 033 private final String m_title; 034 private final String m_description; 035 036 /** 037 * Creation of a new info directive. 038 * @param title the title 039 * @param description the description 040 */ 041 public InfoDirective( final String title, final String description ) 042 { 043 m_title = title; 044 m_description = description; 045 } 046 047 /** 048 * Return the resource title. 049 * @return the title 050 */ 051 public String getTitle() 052 { 053 return m_title; 054 } 055 056 057 /** 058 * Return the resource description. 059 * @return the description 060 */ 061 public String getDescription() 062 { 063 return m_description; 064 } 065 066 /** 067 * Return the null status of the info block. 068 * @return the null status 069 */ 070 public boolean isNull() 071 { 072 return ( ( null == m_title ) && ( null == m_description ) ); 073 } 074 075 /** 076 * Compare this object with another for equality. 077 * @param other the other object 078 * @return true if equal 079 */ 080 public boolean equals( Object other ) 081 { 082 if( super.equals( other ) && ( other instanceof InfoDirective ) ) 083 { 084 InfoDirective info = (InfoDirective) other; 085 if( !equals( m_title, info.m_title ) ) 086 { 087 return false; 088 } 089 else 090 { 091 return equals( m_description, info.m_description ); 092 } 093 } 094 else 095 { 096 return false; 097 } 098 } 099 100 /** 101 * Compute the hash value. 102 * @return the hashcode value 103 */ 104 public int hashCode() 105 { 106 int hash = super.hashCode(); 107 hash ^= super.hashValue( m_title ); 108 hash ^= super.hashValue( m_description ); 109 return hash; 110 } 111 }